import { getTemplatelist, getMyApply } from '../services';

export default {
    namespace: 'flowList',
    state: {
        listData: [],
        myApplicationData: [],
        categoryType: []
    },
    effects: {
        *fetch({ payload }, { call, put }) {
            const result = yield call(getTemplatelist, payload);
            if (result && result.code === 10000) {
                yield put({
                    type: 'save',
                    payload: {
                        listData: result.data
                    }
                });
            }
        },
        *fetchMyApply({ payload }, { call, put }) {
            const result = yield call(getMyApply, payload);
            if (result && result.code === 10000) {
                yield put({
                    type: 'save',
                    payload: {
                        myApplicationData: result.data
                    }
                });
            }
        }
    },
    reducers: {
        save(state, { payload }) {
            return {
                ...state,
                ...payload
            };
        }
    }
};
